using System.Windows;
using AFEParserWPF.ViewModels;

namespace AFEParserWPF.Views;

/// <summary>
/// 应用主窗口
/// </summary>
public partial class MainWindow : Window
{
    /// <summary>
    /// 初始化主窗口
    /// </summary>
    public MainWindow()
    {
        InitializeComponent();
        DataContext = new MainWindowViewModel();
        
        // 启用拖放
        AllowDrop = true;
        Drop += MainWindow_Drop;
    }
    
    /// <summary>
    /// 处理拖放事件
    /// </summary>
    private void MainWindow_Drop(object sender, System.Windows.DragEventArgs e)
    {
        if (DataContext is MainWindowViewModel viewModel)
        {
            viewModel.HandleDropCommand.Execute(e.Data);
            e.Handled = true;
        }
    }
}
